@extends('layouts.app')
@section('content')
<div class="content">
    <a class="btn btn-info btn-sm" href="{{ redirect()->back()->getTargetUrl() }}"> 返回 </a>
    <br>
    <br>

    <div class="row">
        

        <div class="col-md-6">
            <div class="box box-success">
                <div class="panel-heading"> 添加 </div>
                <div class="panel-body">

                    <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="{{ route('admin.template.store') }}">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
                        <input type="hidden" name="type" value="{{$type}}">
                        <div class="form-group">
                            <label class="control-label col-xs-12 col-sm-2">场景名称</label>
                            <div class="col-xs-12 col-sm-8">
                                <input type="text" class="form-control editor" name="scene">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-xs-12 col-sm-2">模板id</label>
                            <div class="col-xs-12 col-sm-8">
                                <input type="text" class="form-control editor" name="template_id">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-xs-12 col-sm-2">消息开始语</label>
                            <div class="col-xs-12 col-sm-8">
                                <textarea class="form-control editor" style="resize:none;" rows="5" name="first" cols="50"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-xs-12 col-sm-2"></label>
                            <div class="col-xs-12 col-sm-8">
                                <div class="input-group">
                                    <div class="input-group-addon no-border no-padding">
                                        <span><button type="button" class="btn btn-danger" id="add_keyword"><i class="fa fa-plus"></i> 添加关键字</button></span>
                                    </div>
                                    <input id="keyword" class="form-control" size="50" type="text" value="">
                                </div>
                            </div>
                        </div>
                        <div id="html">
                            
                        </div>
                        <div class="form-group">
                            <label class="control-label col-xs-12 col-sm-2">消息结束语</label>
                            <div class="col-xs-12 col-sm-8">
                                <textarea id="c-content" class="form-control editor" style="resize:none;" rows="5" name="remark" cols="50"></textarea>
                            </div>
                        </div>
                        <div class="form-group layer-footer">
                            <label class="control-label col-xs-12 col-sm-2"></label>
                            <div class="col-xs-12 col-sm-8">
                                <button type="submit" class="btn btn-success btn-embossed">确定</button>
                                <button type="reset" class="btn btn-default btn-embossed">重置</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>


</div>
@endsection
@push('scripts')
<script>
    $('#add_keyword').click(function(){

        keyword = $('#keyword').val()
        // if(keyword == '')  
            // $('#warning_text').text('关键字不能为空')

        $html = '<div class="form-group keyword"><label class="control-label col-xs-12 col-sm-2">'+keyword+'<input type="hidden" value="'+keyword+'" name="keyword_key[]"></label><div class="col-xs-12 col-sm-8"><div class="input-group"><input class="form-control" size="50" name="keyword_value[]" type="text" value=""><div class="input-group-addon no-border no-padding"><span><button type="button" class="btn btn-danger" onclick="del(this)"><i class="fa fa-plus"></i> 删除</button></span></div><span class="msg-box n-right" for="c-image"></span></div></div></div>';

        $('#html').append($html)
        
    })

    function del(obj){

        $(obj).parents('.keyword').remove()
        
    }

</script>
@endpush
